package com.myapp.model;

import java.io.Serializable;
import java.util.Date;
import javax.jdo.annotations.*;

import com.google.appengine.api.users.User;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
@Query(name="latestPropertys",
       value="select from com.myapp.model.Property order by date desc range 0,5")
public class Property implements Serializable
{
    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;

    @Persistent
    private User author;

    @Persistent(nullValue = NullValue.EXCEPTION)
    private String propertyName;

	// Property objects have a valuetype
	/*
		string, text
		number
		enum
		boolean
		location
		color
		image
		link
		date
		
		
	*/

    @Persistent(nullValue = NullValue.EXCEPTION)
    private ValueType valueType;

	
    @Persistent(nullValue = NullValue.EXCEPTION)
    private Date date;

    public Property(User author, String propertyName, ValueType valueType, Date date) {
        this.author = author;
        this.propertyName = propertyName;
        this.valueType = valueType;
        this.date = date;
    }

    public Long getId() {
        return id;
    }

    public User getAuthor() {
        return author;
    }

    public String getPropertyName() {
        return propertyName;
    }

    public ValueType getValueType() {
        return valueType;
    }

    public Date getDate() {
        return date;
    }
}
